package com.github.mvc.domain;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 处理器映射器
 *
 * @author ArchieSean
 * @create 2023/8/31
 */

public class Handler {
    /**
     * 目标方法
     */
    private Method method;
    /**
     * 接口所在类
     */
    private Object controller;
    /**
     * 请求路径
     */
    private Pattern pattern;
    /**
     * 参数顺序,key: 参数名 ，value: 参数顺序
     */
    private Map<String, Integer> paramIndexMapping;

    public Handler(Method method, Object controller, Pattern pattern) {
        this.method = method;
        this.controller = controller;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }
}
